# Based on https://github.com/ivansafrin/Polycode/blob/master/CMake/FindAssimp.cmake
# - Try to find Assimp
# Once done this will define
#
# ASSIMP_FOUND - system has Assimp
# ASSIMP_INCLUDE_DIR - the Assimp include directory
# ASSIMP_LIBRARY - Link these to use Assimp
# ASSIMP_LIBRARIES

set(ASSIMP_SEARCH_PATHS "$ENV{ASSIMP_DIR}" CACHE PATH "Location of Assimp")

# check if system is 32bit or 64bit
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
	set(BINARY_DIR "x64")
else()
	set(BINARY_DIR "x86")
endif()

find_path(ASSIMP_INCLUDE_DIR assimp/scene.h
	PATHS
	${ASSIMP_SEARCH_PATHS}/include
)
 
find_library(ASSIMP_LIBRARY_RELEASE
	NAMES assimp
	PATHS ${ASSIMP_SEARCH_PATHS}/lib/${BINARY_DIR}
)

find_library(ASSIMP_LIBRARY_DEBUG
	NAMES assimpd
	PATHS ${ASSIMP_SEARCH_PATHS}/lib/${BINARY_DIR}
)

if (ASSIMP_INCLUDE_DIR AND ASSIMP_LIBRARY_RELEASE)
  set(ASSIMP_FOUND TRUE)
endif()

if(ASSIMP_LIBRARY_RELEASE)
    set(ASSIMP_LIBRARY debug ${ASSIMP_LIBRARY_RELEASE} optimized ${ASSIMP_LIBRARY_RELEASE} )
endif()


if(ASSIMP_FOUND)
  MESSAGE(STATUS "Assimp found ${ASSIMP_LIBRARY}")
  mark_as_advanced (ASSIMP_INCLUDE_DIR ASSIMP_LIBRARY)
endif()